﻿Imports System.Data.OleDb

Public Class tagcloud
    Inherits System.Web.UI.Page
    Dim maxNo

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim SqlTag As String = "SELECT MAX(CountOfCT_FID) FROM CountAllTags"
        Dim conntag As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("CakeConnection").ConnectionString)
        Dim cmdtag As OleDbCommand = New OleDbCommand(SqlTag, conntag)
        conntag.Open()

        maxNo = cmdtag.ExecuteScalar()

        conntag.Close()
        cmdtag.Dispose()
        conntag.Dispose()
    End Sub

    Function getTags(ByVal tagCount As Integer, ByVal tag As String)

        Dim myoutput As String = "<DIV CLASS STYLE=font-size:"
        Dim myresult As Double
        myresult = (tagCount / maxNo) * 100
        myresult = myresult * 1.5
        Dim roundresult As Integer
        roundresult = Convert.ToInt32(myresult)
        If maxNo = 1 Then
            'Only one tag each so 12px
            myoutput = myoutput & "12px;float:left;>" & "<a href=cakeByTags.aspx?tag=" & tag & ">" & tag & "</a> </div>"
        Else
            myoutput = myoutput & roundresult & "px;float:left;>" & "<a href=cakeByTags.aspx?tag=" & tag & ">" & tag & "</a> </div>"
        End If


        Return myoutput
    End Function

End Class